package com.hcms.admin.controller.common;

import com.hcms.admin.annotation.CheckPermission;
import com.hcms.common.api.CommonResponse;
import com.hcms.common.dto.CaptchaResult;
import com.hcms.common.service.ICaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 帮助分类表 前端控制器
 * </p>
 *
 * @author achenxw@126.com
 * @since 2023-02-14
 */
@RestController
@RequestMapping("/captcha")
public class CaptchaController {

    @Autowired
    private ICaptchaService captchaService;

    @GetMapping("/generator")
    @CheckPermission(check = false)
    public ResponseEntity<CommonResponse<CaptchaResult>> generator(@RequestParam(defaultValue = "90", required = false) Integer width, @RequestParam(defaultValue = "32", required = false) Integer height) {
        CaptchaResult generator = captchaService.generator(width, height);
        return CommonResponse.ok(generator);
    }

}
